The TreeView control is used to display a hierarchy of nodes. You can expand and collapse these nodes by clicking them.
How to use TreeView control
Drag and drop TreeView from toolbox on the window Form
Code:
Public Class mindstick
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'adding data in TreeView
TreeView1.Nodes.Add("Database") 'this is root node
TreeView1.Nodes(0).Nodes.Add("sql server")
TreeView1.Nodes(0).Nodes.Add("my sql")
TreeView1.Nodes(0).Nodes.Add("Oracle")
TreeView1.Nodes.Add("Programming langauage")'this is root node
TreeView1.Nodes(1).Nodes.Add("C#")
TreeView1.Nodes(1).Nodes.Add("VB")
TreeView1.Nodes(1).Nodes.Add("Java")
End Sub
End Class
Run the project
When you expand the Database node then the child node of the database will show.
TreeView Properties
ShowRootLine: set the ShowRootLine to show or hide Line, By default, it is set to true.
ForeColor: ForeColor of TreeView can be changed through TreeView ForeColor property.
Private Sub Form19_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'change TreeView ForeColor
TreeView1.ForeColor = Color.Red
End Sub
BackColor: BackColor of TreeView can be changed through TreeView BackColor property.
Private Sub Form19_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'change TreeView BckColor
TreeView1.BackColor = Color.PowderBlue
End Sub
Leave Comment